package com.jungle.bfi.entity;

import com.jungle.base.entity.BasePo;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Objects;

/**
 * [metadata]DataDefinition数据定义实体
 */
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_data_definition")
public class DataDefinitionPo extends BasePo<String> {
    @Id
    private String id;
    /**
     * 接口标识
     */
    private String apiId;
    /**
     * 接口请求路径
     */
    private String apiPath;
    /**
     * NC标题
     */
    private String title;

    private String name;
    private String nameJsonPath;

    private String code;
    private String codeJsonPath;
    /**
     * 业务场景标识因子数据
     */
    private Boolean scenarioFlag;
    /**
     * 是否必填项
     */
    private Boolean required;
    /**
     * 业务数据类型-编码
     */
    private String categoryValue;

    /**
     * 数据源类型：api-接口返回数据，enum-枚举数据
     */
    private String dataSourceType;
    /**
     * 数据集标识
     */
    private String datasetId;
    /**
     * 数据集名称
     */
    private String datasetName;

    public DataDefinitionPo(String apiId, String apiPath) {
        this.apiId = apiId;
        this.apiPath = apiPath;
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || getClass() != object.getClass()) return false;
        if (!super.equals(object)) return false;
        DataDefinitionPo that = (DataDefinitionPo) object;
        return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(code, that.code);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), id, name, code);
    }
}
